template = """
`timescale 1ns / 100ps

module sha256_tb ();

    localparam DATA_WIDTH = {0};

    reg  clk;
    reg  rst_n;
    reg  start;
    reg  [DATA_WIDTH-1:0] in_data;
    wire finish;
    wire [255:0] sha_data;

    initial begin
        $dumpfile("./output/sha256.vcd");
        $dumpvars(0, u_sha256);

        in_data = {1};
        clk = 0;
        rst_n = 1;
        #1; rst_n = 0;
        #1; rst_n = 1;
        #6; start = 1;
        #10; start = 0;

        #{2}

        $finish;
    end

    always #10 clk = ~clk;

    sha256#(.DATA_WIDTH(DATA_WIDTH)) u_sha256 (
        .clk(clk),
        .rst_n(rst_n),
        .start(start),
        .in_data(in_data),
        .sha_data(sha_data),
        .finish(finish)
    );

endmodule
"""

s = '3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196442881097566593344612847564823378678316527120190914564856692346034861045432664821339360726024914127372458700660631558817488152092096282925409171536436789259036001133053054882046652138414695194151160943305727036575959195309218611738193261179310511854807446237996274956735188575272489122793818301194912983367336244065664308602139494639522473719070217986094370277053921717629317675238467481846766940513'
# s = 'hello'

with open('sha256_tb.v', 'w') as file:
    data_width = len(s) * 8
    block_size = (((data_width + 1 + 64) + 511) // 512)

    byte_array = '{'
    for (i, c) in enumerate(s):
        if i != 0:
            byte_array += ', '
        byte_array += f"8'd{ord(c)}"
    byte_array += '}'

    deley_periods = block_size * 70 * 20
    
    file.write(template.format(data_width, byte_array, deley_periods))